<template>
  <div class="shopList_container">
    <div class="shopList_nearby">
      <img src="./images/more.png" alt="更多店铺列表" />
      <span>附近商家</span>
    </div>
    <div
      class="shopList_detail"
      v-for="(item,index) in shopList"
      :key="index"
      @click="gotoShopDrtails(item.id)"
    >
      <div>
        <img :src="'http://elm.cangdu.org/img/'+item.image_path" alt />
      </div>
      <div class="shopList_info">
        <div class="name">
          <h3>{{item.name}}</h3>
          <img src="./images/more.png" alt="评分图" />
          <span>评分:{{item.rating}}</span>
          <p>￥{{item.float_minimum_order_amount}}元起送，费送费约￥{{item.float_delivery_fee}}元</p>
        </div>
        <div class="detance">
          <span>蜂鸟专送</span>
          <p>687m_22分钟</p>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { getShopList } from "../../api/index.js";
export default {
  data() {
    return {
      shopList: []
    };
  },
  created() {
    wx.request({
      url: getShopList,
      success: res => {
        this.shopList = res.data;
      },
      fail: res => {
        console.log("请求数据失败");
      }
    });
  },
  methods: {
    gotoShopDrtails(shopID) {
      wx.navigateTo({
        url: "/pages/shopDetail/main?id=" + shopID
      });
    }
  }
};
</script>
<style lang="scss" scoped>
.shopList_container {
  display: flex;
  flex-direction: column;
  background-color: #f5f5f5;
  padding-top: 20rpx;
  .shopList_nearby {
    display: flex;
    background-color: #ffffff;
    padding: 15rpx;
    img {
      width: 40rpx;
      height: 40rpx;
    }
  }
  .shopList_detail {
    display: flex;
    padding: 20rpx 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    div {
      flex: 2;
      margin-left: 20rpx;
    }
    img {
      width: 140rpx;
      height: 120rpx;
    }
    .shopList_info {
      flex: 8;
      display: flex;
      justify-content: space-between;
      color: #808080;
      font-size: 20rpx;
      margin-left: 20rpx;

      .name {
        display: flex;
        flex-direction: column;
        overflow: hidden; /*自动隐藏文字*/
        text-overflow: ellipsis; /*文字隐藏后添加省略号*/
        white-space: nowrap; /*强制不换行*/
        h3 {
          font-weight: bold;
          font-size: 32rpx;
          color: black;
        }
        img {
          width: 30rpx;
          height: 30rpx;
        }
      }
      .detance {
        display: flex;
        flex-direction: column;
        justify-content: center;
        margin-right: 20rpx;
        span {
          background-color: #008fff;
          color: white;
          text-align: center;
          padding: 10rpx;
          border-radius: 10rpx;
        }
      }
    }
  }
}
</style>
